progressbar: Change the way the progress gadget gets size
authorBenjamin Otte <otte@redhat.com>
Wed, 16 Dec 2015 00:44:07 +0000 (01:44 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 16 Dec 2015 00:50:01 +0000 (01:50 +0100)
Size of the progress element now grows also when it's close to 0 size.

Previously the size was clamped to the minimum size, now it starts
growing from the minimum size.
So for a 100px trough with a 10px min size progress, the sizes of the
progress element change like this:
        old     new
0%      10      10
5%      10      14
10%     10      19
20%     20      28
50%     50      55
100%    100     100

gtk/gtkprogressbar.c

index 7adf76bbf3e29852c1ab2544d70d00d1b8194537..587fad542ecee7111dc64433a7ec5d532c82c1fc 100644 (file)
@@ -1068,7 +1068,7 @@ gtk_progress_bar_allocate_trough (GtkCssGadget        *gadget,
     {
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          alloc.width = MAX (width, allocation->width / priv->activity_blocks);
+          alloc.width = width + (allocation->width - width) / priv->activity_blocks;
           alloc.x = allocation->x + priv->activity_pos * (allocation->width - alloc.width);
           alloc.y = allocation->y + (allocation->height - height) / 2;
           alloc.height = height;
@@ -1076,7 +1076,7 @@ gtk_progress_bar_allocate_trough (GtkCssGadget        *gadget,
       else
         {
 
-          alloc.height = MAX (height, allocation->height / priv->activity_blocks);
+          alloc.height = height + (allocation->height - height) / priv->activity_blocks;
           alloc.y = allocation->y + priv->activity_pos * (allocation->height - alloc.height);
           alloc.x = allocation->x + (allocation->width - width) / 2;
           alloc.width = width;
@@ -1086,7 +1086,7 @@ gtk_progress_bar_allocate_trough (GtkCssGadget        *gadget,
     {
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          alloc.width = MAX (width, allocation->width * priv->fraction);
+          alloc.width = width + (allocation->width - width) * priv->fraction;
           alloc.height = height;
           alloc.y = allocation->y + (allocation->height - height) / 2;
 
@@ -1098,7 +1098,7 @@ gtk_progress_bar_allocate_trough (GtkCssGadget        *gadget,
       else
         {
           alloc.width = width;
-          alloc.height = MAX (height, allocation->height * priv->fraction);
+          alloc.height = height + (allocation->height - height) * priv->fraction;
           alloc.x = allocation->x + (allocation->width - width) / 2;
 
           if (!inverted)